import copy

import pandas as pd

import config
def save_scheme(scheme):
    schemes = copy.deepcopy(scheme)
    new_data = []
    for sch in schemes:
        new_item = [sch[1],sch[2],sch[3],sch[4],sch[5][0],sch[5][1]]
        new_data.append(new_item)
    column_names = ['课程号', '班级号', '限制人数', '是否需要教室', '教室', '时间']
    df = pd.DataFrame()
    for i, col_name in enumerate(column_names):
        df[col_name] = [row[i] for row in new_data]
    file_path = 'data1/scheme.xlsx'  # 指定文件路径和名称
    sheet_name = 'Sheet1'  # 工作表名称

    df.to_excel(file_path, sheet_name=sheet_name, index=False)


def save_data(exp_data):
    column_names=['实例','教师惩罚','时间惩罚', '学生约束惩罚','总惩罚','时间']
    df = pd.DataFrame()
    for i,column_name in enumerate(column_names):
        df[column_name] =[row[i] for row in exp_data]
    file_path = 'data1/scheme1.xlsx'
    sheet_name = 'Sheet1'

    df.to_excel(file_path, sheet_name=sheet_name, index=False)